package com.cssy.xxkj.basic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicStorageLocationDAO;
import com.cssy.xxkj.basic.entity.BasicStorageLocationDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-04
 */
public class BasicStoragelocationDAOImpl extends SqlMapClientDaoSupport implements BasicStorageLocationDAO {

    /**
     * 插入数据
     * @param basicStoragelocationDO
     * @return 插入数据的主键
     */
    public String insertBasicStoragelocationDO(BasicStorageLocationDO basicStoragelocationDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("BasicStoragelocation.insert", basicStoragelocationDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicStoragelocationDO
     * @return 查出的记录数
     */
    public Integer countBasicStoragelocationDOByExample(BasicStorageLocationDO basicStoragelocationDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicStoragelocation.countByDOExample", basicStoragelocationDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicStoragelocationDO
     * @return 受影响的行数
     */
    public Integer updateBasicStoragelocationDO(BasicStorageLocationDO basicStoragelocationDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("BasicStoragelocation.update", basicStoragelocationDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicStoragelocationDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicStorageLocationDO> findListByExample(BasicStorageLocationDO basicStoragelocationDO) throws DataAccessException {
        List<BasicStorageLocationDO> list = getSqlMapClientTemplate().queryForList("BasicStoragelocation.findListByDO", basicStoragelocationDO);
        return list;
    }

    /**
     * 根据主键获取basicStoragelocationDO
     * @param id
     * @return basicStoragelocationDO
     */
    public BasicStorageLocationDO findBasicStoragelocationDOByPrimaryKey(String id) throws DataAccessException {
        BasicStorageLocationDO basicStoragelocationDO = (BasicStorageLocationDO) getSqlMapClientTemplate().queryForObject("BasicStoragelocation.findByPrimaryKey", id);
        return basicStoragelocationDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicStoragelocationDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicStoragelocation.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<BasicStorageLocationDO> find(SearchConditions scs) throws DataAccessException {
		List<BasicStorageLocationDO> list = getSqlMapClientTemplate().queryForList("BasicStoragelocation_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicStoragelocation_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		int result = (Integer)getSqlMapClientTemplate().queryForObject("BasicStoragelocation_ex.deleteBizRemoved", id);
        return result;
	}

}